package com.bigdata.movieticketapi.config;

import com.bigdata.movieticketapi.filter.TokenFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class FilterConfig {
    @Bean
    public TokenFilter tokenFilter(){
        return new TokenFilter();
    }

    @Bean
    public FilterRegistrationBean tokenFilterBean(TokenFilter tokenFilter){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(tokenFilter);
        filterRegistrationBean.setName("tokenFilter");
        filterRegistrationBean.addUrlPatterns("/api/admin/*");
        return filterRegistrationBean;
    }
}
